<?php
header("Access-Control-Allow-Origin: *");
header('Access-Control-Allow-Methods:*');
header('Access-Control-Allow-Headers:*');
header("Access-Control-Request-Headers: *");

// 定义应用目录
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', realpath('../') . DS);
define('APP', ROOT . 'app');
define('APP_MODULE', 'app');
define('CORE', ROOT . 'core');
define('RUNTIME', ROOT . 'core');

// 引入自动加载
require __DIR__ . '/../vendor/autoload.php';

// 载入自定义函数 composer.json->autoload->files
// include CORE . '/common/function.php';

// 自定义加载器
include CORE . '/Base.php';
include CORE . '/Env.php';

// 调试
define('DEBUG', env('app_debug', false));
if (DEBUG) {
    // 引入第三方错误展示
    $whoops = new \Whoops\Run;
    $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
    $whoops->register();
    ini_set('display_error', 'On');
} else {
    ini_set('display_error', 'Off');
}

// 路由解析器
spl_autoload_register('\core\Base::load');

\core\Base::run();

// api demo 127.0.0.1:82/admin/test/test